//
//  BarButtonItem+extensions.swift
//  WeiBo
//
//  Created by 尹琼 on 2017/5/3.
//  Copyright © 2017年 尹琼. All rights reserved.
//

import UIKit

// MARK: - 自定义UIBarButtonItem
extension UIBarButtonItem {
    
    /// 返回按钮样式  "navigationbar_back_withtext"
    ///
    /// - Parameters:
    ///   - title: 主题
    ///   - taget: 响应链
    ///   - action: 响应事件
    /// - Returns: item
    static func backItem(title: String?, taget: AnyObject?, action: Selector) ->UIBarButtonItem  {
        let item:UIBarButtonItem =  UIBarButtonItem(title: title, imageName: "navigationbar_back_withtext", taget: taget, action: action)
        return item
    }
    
    /// 闭包形式button 转Item
    ///
    /// - Parameters:
    ///   - title: 主题
    ///   - image: 主题图
    ///   - taget: 响应链
    ///   - other: 其他设置的闭包
    ///   - select: 响应方法
    /// - Returns: UIBarButtonItem
    convenience init(title: String?, imageName:String?, taget: AnyObject?, action: Selector) {
        let button: UIButton = UIButton(title: title, imageName: imageName, taget: taget, action: action)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        //设置默认的几个属性，如需要更改可以在otger闭包中进行
        self.init(customView: button)
    }
}
